package com.miyuan.wm.response;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;
import java.util.List;

/**
 * @ClassName PageResponse
 * @Description 分页返回基础响应
 */
@Data
@ApiModel(value = "分页返回基础响应", description = "分页返回基础响应")
public class PageResponse<T> implements Serializable {

    @ApiModelProperty(value = "状态码", notes = "状态码")
    private Integer errCode = 200;

    @ApiModelProperty(value = "返回值描述", notes = "返回值描述")
    private String errMsg;

    @ApiModelProperty(value = "当前时间戳", notes = "当前时间戳")
    private String timeStamp;

    @ApiModelProperty(value = "总记录数", notes = "总记录数")
    private long count;

    @ApiModelProperty(value = "当前页数", notes = "当前页数")
    private long pageIndex;

    @ApiModelProperty(value = "总页数", notes = "总页数")
    private long pageSize;

    @ApiModelProperty(value = "返回值", notes = "返回值")
    private T data;

    public PageResponse(){}

    public PageResponse(T data, long count, long pageIndex, long pageSize) {
        this.data = data;
        this.count = count;
        this.pageIndex = pageIndex;
        this.pageSize = pageSize;
    }

    public static <T> PageResponse<T> newInstance(T data, long count, long pageIndex, long pageSize) {
        return new PageResponse(data, count, pageIndex, pageSize);
    }

}
